package com.gjzxdk.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.gjzxdk.pojo.User;
import com.gjzxdk.service.IUserService;

@Controller
@RequestMapping("/user")
public class UserController {
	
	@Resource
	private IUserService userService;
	
	@RequestMapping("/showUser")
	public String toIndex(HttpServletRequest request,Model model){
		int userId = Integer.parseInt(request.getParameter("id"));
		User user = this.userService.getUserById(userId);
		model.addAttribute("user111", user);
		return "showUser";
	}
	
	@ResponseBody
	@RequestMapping("/testJsonp")
	public Object testJsonp(String callback){
		System.out.println("callback:"+callback);
		User user = this.userService.getUserById(1);
		MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(user);  
		mappingJacksonValue.setJsonpFunction(callback);  
		return mappingJacksonValue;
	}
	 
}
